var mongoose = require('mongoose')
var Schema = mongoose.Schema;

var userRoutersModel = new Schema({  //约定表结构
  name:{
    type: String,
    required: [false, '路由名不能为空'],
    minlength: [1, '路由名最小长度是1'],
    maxlength: [30, '路由名最大长度是30'],
    trim: true
  },
  title: {
    type: String,
    required: [true, '标题不能为空'],
    minLength:[1,'标题最小长度为1'],
    maxLength: [30, '标题最大长度为30'],
    trim: true
  },
  path: {
    type: String,
    required: [false, "路径不能为空"],
    minlength: [1, '路径最小长度是1'],
    maxlength: [30, '路径最大长度是30'],
    trim: true
  },
  parentId: {//路由的父级菜单名 一级菜单为0
    type: String,
    default:'0',
    required: [false, "父级不能为空"],
    minlength: [1, '父级ID最小长度是1'],
    maxlength: [60, '父级ID最大长度是30'],
    trim: true
  },
  parentName: {
    type: String,
    maxlength: [30, '最大长度是30'],
    trim: true
  },
  isWhite: {//是否是白名单
    type: Boolean,
    default:false
  },
  auth: {//权限字段名
    type: String,
    maxlength: [30, '权限名最大长度是30'],
    trim: true
  },
  cache: {//是否缓存
    type: Boolean,
    default:false
  },
  hidden: {//是否显示在routerTags菜单上
    type: Boolean,
    default:false
  },
  icon:{//路由所带的icon名
    type: String,
    maxlength: [60, 'icon名最大长度是60'],
    trim: true
  },
  component: {
    type: [String],
    default: undefined,
  },
  ownerId: {
    type: String,
  },
  ownerName: {
    type: String,
    minlength: [1, '路径最小长度是1'],
    maxlength: [30, '路径最大长度是30'],
    trim: true
  },
  isMenu: {
    type: Boolean,
    default:false
  }
},{timestamps: true })

var userRoutersSchema = mongoose.model('userRoutersModel',userRoutersModel) //操作对应数据表的数据模型对象

module.exports = userRoutersSchema